﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TestApi.Models;

namespace TestApi.Db
{
  

    public class GithubDbContext : DbContext
    {
        public DbSet<Left> Lefts { get; set; }

        public DbSet<Right> Rights { get; set; }
        public GithubDbContext(DbContextOptions<GithubDbContext> options)
             : base(options)
        {

        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Entity<Left>();
               
            modelBuilder.Entity<Right>()
                .HasOne<Left>().WithOne().HasForeignKey<Right>(x => x.LeftId);

        }
    }


}
